package com.adaxi.adc.business.passengertrip.controller;

import com.adaxi.adc.common.common.CommonResult;
import com.adaxi.adc.common.dto.CarpoolRequest;
import io.swagger.annotations.Api;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "adxi拼车接口文档", tags = "adxi拼车接口文档")
@RestController
public class CarpoolingDemoController {

    final RocketMQTemplate rocketMQTemplate;

    public CarpoolingDemoController(RocketMQTemplate rocketMQTemplate) {
        this.rocketMQTemplate = rocketMQTemplate;
    }


    /**
     * 加入拼车通知司机测试
     */
    @PostMapping("/pooling")
    public CommonResult pooling(@RequestBody CarpoolRequest request) {
        System.out.println("request = " + request);
        rocketMQTemplate.syncSend("pooling-topic", request);
        return CommonResult.SUCCESS("拼车消息已经发送");
    }
}
